$(function(){
	//------------------------------------------------------------------------------------------------------------------
	//个人会员手机号码验证
	$.validator.addMethod("checkMobile", function(value, element, param){
		var regu = /(^1[3-9]{1}[0-9]{9}$)/g;
		if(regu.test(value)){
			return true;
		}else{
			return false;
		}
	}, "请输入正确的手机号码");


	//企业会员表单验证 使用jQuery Validate 插件进行验证
	$('#resumeForm').validate({
		//指定使用什么标签标记错误。
		errorElement: "span",
		//一个函数，可以自定义错误放到哪里。
		errorPlacement: function(error, element){
			$(element).parents('dl').find(".errinfo").append(error);
		},
		//自定义错误消息
		tipPlacement: function(element, tip){
			$(element).parents('dl').find(".errinfo").append(tip);
		},
		//通过验证后执行的函数
		success: function(label){
			if(label.parents('dl').find('dd input').val() != ''){
				label.text('ok!').addClass('success');
			}
		},
		//未验证后执行的函数
		highlight: function(element, errorClass){
			$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
		},
		ignore: "",
		//js上面添加验证规则
		rules: {
			name: {
				required: true
			},
			sex: {
				required: true
			},
			birthday: {
				required: true
			},
			education: {
				required: true
			},
			mobile: {
				required: true,
				minlength: 11,
				checkMobile:true, //期望的是true,如果为false则展示提示信息
				remote: {
					url:'/personal/ajax_mobile',                 //后台处理程序
					type: "post",               //数据发送方式
					data: {                     //要传递的数据
						mobile: function() { return $("#mobile").val();},
						_token: _token
					},
					dataType: "html",
					dataFilter: function(data, type) {
						return (data == "true") ? true : false;
					}
				}
			},
			jobsort1: {
				required: true
			},
			jobarea1: {
				required: true
			},
			intentionjobs: {
				required: true
			}
		},
		//错误信息提示修改
		messages: {
			name: {
				required: "请输入姓名"
			},
			sex: {
				required: "请选择性别"
			},
			birthday: {
				required: "请选择出生年月"
			},
			education: {
				required: "请选择最高学历"
			},
			mobile: {
				required: "请输入手机号码",
				minlength: "手机号码长度必须是11位数字",
				remote: $.validator.format('手机号码已经被注册，请重新输入')
			},
			jobsort1: {
				required: "请选择工作岗位"
			},
			jobarea1: {
				required: "请选择工作地区"
			},
			intentionjobs: {
				required: "请输入意向岗位"
			}
		},
		submitHandler: function(form){
			form.submit();
		}
	});
	//$('form input[placeholder]').placeholder({isUseSpan:true});
});

// ----------------------------------------------------------------------------------------------------------------------------

